package com.example.springbootdemo.serviceImpl;

import com.example.springbootdemo.dto.UserLoginDTO;
import com.example.springbootdemo.mapper.UserMapper;
import com.example.springbootdemo.pojo.UserLogin;
import com.example.springbootdemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;

    @Override
    public UserLogin loginCheck(String userAccount, String userPwd) {
        UserLoginDTO userLoginDTO = userMapper.selectUserInfo(userAccount,userPwd);
        if (userLoginDTO!=null) {
            return new UserLogin(userLoginDTO.getUserAccount(),userLoginDTO.getUserPwd());
        }

        return null;
    }

    @Override
    public UserLogin loginCheck(int userNo) {
        UserLoginDTO userLoginDTO = userMapper.selectUserInfoById(userNo);
        if (userLoginDTO!=null) {
            return new UserLogin(userLoginDTO.getUserAccount(),userLoginDTO.getUserPwd());
        }

        return null;
    }
}
